import json
from http.client import responses

import requests

# url = "http://httpbin.org/get?name=qiku"
#
# response = requests.get(url,params={"age":"10","addr":"北京"})
#
# if response.status_code == 200:
#     # response_bytes = response.content
#     # print(response_bytes,11111)
#     # response_text = response_bytes.decode("utf-8")
#     # response_json = json.loads(response_text)
#     # print(response_json,2222)
#     response_json = response.json()
#     print(response_json)
#     print(response.request.headers)
#     print(response_json['headers']['User-Agent'],response_json['args'])


url = "http://httpbin.org/post?name=qiku"

response = requests.post(url, headers={"user-agent":
                               "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0",

                       },
                        data={"age":"10","addr":"北京"})

if response.status_code == 200:
    # response_bytes = response.content
    # print(response_bytes,11111)
    # response_text = response_bytes.decode("utf-8")
    # response_json = json.loads(response_text)
    # print(response_json,2222)
    response_json = response.json()
    print(response_json)
    print(response.request.headers)
    print(response_json['headers']['User-Agent'],response_json['args'])